package com.yzy.fly.entity.role;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
@Data
@TableName("fly_attribute")
public class FlyAttribute implements Serializable {

    @TableId(type = IdType.AUTO)
    private Integer id;

    private String label;
    private String name;
    private Integer seq;
    private String type;//类还是列表
    private String structType;//类还是列表,数组
    private String classPath;
    private String isValid;
    private String tag;
    private String subTag;
    private Integer modelId;
    private Integer defModelId;
    private Integer systemId;
    private Date createTime;
    private Date updateTime;

    private String version;
    private Integer access;
    private String fieldName;

    private String columnName;
    private Integer primaryKey; //0不是 1是
    private Integer autoIncrement;

    private Boolean isExsitDatabase;

    @TableField(exist = false)
    private FlyAttributeWidget widget;

    public FlyAttribute copy(){
        return copy(this);
    }

    public FlyAttribute copy(FlyAttribute flyAttribute){
        FlyAttribute newFlyAttribute = new FlyAttribute();
        newFlyAttribute.setLabel(flyAttribute.getLabel());
        newFlyAttribute.setName(flyAttribute.getName());
        newFlyAttribute.setSeq(flyAttribute.getSeq());
        newFlyAttribute.setType(flyAttribute.getType());
        newFlyAttribute.setClassPath(flyAttribute.getClassPath());
        newFlyAttribute.setIsValid(flyAttribute.getIsValid());
        newFlyAttribute.setTag(flyAttribute.getTag());
        newFlyAttribute.setCreateTime(new Date());
        newFlyAttribute.setUpdateTime(new Date());
        newFlyAttribute.setVersion(flyAttribute.getVersion());
        newFlyAttribute.setAccess(flyAttribute.getAccess());
        newFlyAttribute.setFieldName(flyAttribute.getFieldName());
        return newFlyAttribute;
    }

    public FlyAttribute copy(FlyModel flyModel){
        FlyAttribute newFlyAttribute = copy(this);
        newFlyAttribute.setModelId(flyModel.getId());
        newFlyAttribute.setDefModelId(flyModel.getDefModelId());
        newFlyAttribute.setSystemId(flyModel.getSystemId());
        return newFlyAttribute;
    }
}
